Imports System
Imports System.Web
Imports System.Text.UTF8Encoding
Public Class cn_header
    Inherits System.Web.UI.UserControl
    'Public _whichpage As Integer
    Public imgpath As String
    Public objvalid As New gaValidation
    Public currtURL As String
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region
    
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Dim URLpage As String = ReadURLPageName()
        'If InStr(URLpage, "cn_") > 0 Then

        'End If
        'Select Case URLpage.ToLower
        '    Case "default.aspx", "login.aspx"
        '        imgpath = "images"
        '    Case Else
        '        imgpath = "../images"
        'End Select
        '
        objValid.getURL(Request.Url.ToString, imgpath, currtURL)
    End Sub
    Public Sub getURL(ByVal CurrtUrlstring As String, ByRef imgpath As String, ByRef strURL As String)
        'Private Function ReadURLPageName(ByVal strurl As String) As String
        Dim arrTemp As Array
        Dim intPageNamePos As Integer
        Dim imagefd As String = "images"
        Dim strTemp As String
        'Dim arrCurrURL As Array
        'Dim currtURL As String '= Request.Url.ToString

        arrTemp = Split(Currturlstring, "/")
        intPageNamePos = arrTemp.GetUpperBound(0)
        strTemp = arrTemp(intPageNamePos)
        If InStr(strTemp, "cn_") > 0 Then
            imgpath = "/" & arrTemp(intPageNamePos - 2) & "/" & imagefd & ""
        Else
            imgpath = "images"
        End If
        'If strTemp = "adm_default.aspx" Then
        '    strURL = CurrtUrlstring
        '    imgpath = "Admin/images"
        'Else
        '    strURL = "./" & arrTemp(intPageNamePos - 1) & "/" & strTemp & ""
        '    imgpath = "../images"
        'End If
        'If InStr(strTemp, "?") > 0 Then
        '    arrTemp = Split(strTemp, "?")
        '    ReadURLPageName = LCase(arrTemp(0))
        'Else
        '    ReadURLPageName = strTemp
        'End If
    End Sub
    Private Function ReadURLPageName() As String
        Dim arrTemp As Array
        Dim intPageNamePos As Integer
        Dim strTemp As String

        arrTemp = Split(Request.Url.ToString, "/")
        intPageNamePos = arrTemp.GetUpperBound(0)
        strTemp = arrTemp(intPageNamePos)
        If InStr(strTemp, "?") > 0 Then
            arrTemp = Split(strTemp, "?")
            ReadURLPageName = LCase(arrTemp(0))
        Else
            ReadURLPageName = strTemp
        End If
    End Function
End Class
